package com.silence.gankio.mvvm.viewModel

import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MutableLiveData
import com.silence.gankio.bean.GankIoData
import com.silence.gankio.mvvm.model.GankModel
import com.silence.gankio.net.GankIoObjectObserver

class GankAndroidViewModel : BaseViewModel() {

    private val androidData by lazy { MutableLiveData<List<GankIoData>>() }

    fun getAndroidData(): LiveData<List<GankIoData>> = androidData

    fun loadData(showLoadingUI: Boolean, page: Int, number: Int = 10) {
        load(showLoadingUI, mGankIoService.android(number, page), object : GankIoObjectObserver<GankIoData>(this) {
            override fun onSuccess(t: List<GankIoData>?) {
                androidData.value = t
            }
        })
    }

}